import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/AmapControl',
    component: Layout,
    redirect: '/index',
    name: 'ControlView',
    hidden: true,
    children: [{
      path: 'index',
      component: () => import('@/views/Control/index')
    }]
  },
  {
    path: '/home',
    component: Layout,
    redirect: '/dashboard',
    name: 'Home',
    meta: { title: '首页', icon: 'icon-shouye' }

  },
  {
    path: '/control',
    component: Layout,
    redirect: '/AmapControl/index',
    name: 'Control',
    meta: { title: '调度中心', icon: 'icon-zhongxinweizhi' }
  },
  {
    path: '/business',
    component: Layout,
    redirect: '/business/page',
    name: 'BusinessManage',
    meta: { title: '企业管理', icon: 'icon-qiye' },
    children: [
      {

        path: 'page',
        name: 'BusinessPage',
        component: () => import('@/views/business/list'),
        meta: { title: '企业信息', icon: 'table' },
        children: [
          {
            path: 'info',
            name: 'BusinessInfo',
            hidden: true,
            component: () => import('@/views/business/info'),
            meta: { title: '企业详情' }
          }
        ]
      },

      // {
      //
      //   path: 'list',
      //   name: 'BusinessList',
      //   component: () => import('@/views/business/list'),
      //   meta: { title: '额度审批', icon: 'table' }
      // },
      // {
      //
      //   path: 'list',
      //   name: 'BusinessList',
      //   component: () => import('@/views/business/list'),
      //   meta: { title: '结账单', icon: 'table' }
      // }
    ]
  },
  {
    path: '/cys',
    component: Layout,
    redirect: '/cys/list',
    name: 'CysManage',
    meta: { title: '承运商', icon: 'icon-shangjiarenzheng' },
    children: [
      {

        path: 'list',
        name: 'CysList',
        component: () => import('@/views/cysmodel/cys/list'),
        meta: { title: '承运商管理', icon: 'table' }
      },
      {
        path: 'drivers',
        name: 'Drivers',
        component: () => import('@/views/cysmodel/driver/list'),
        meta: { title: '司机管理', icon: 'table' }
      },
      {
        path: 'cars',
        name: 'Cars',
        component: () => import('@/views/cysmodel/car/list'),
        meta: { title: '车辆管理', icon: 'table' }
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/list',
    name: 'OrderManage',
    meta: { title: '订单中心', icon: 'icon-dingdan' },
    children: [
      {

        path: 'list',
        name: 'OrderList',
        component: () => import('@/views/order/list'),
        meta: { title: '订单管理', icon: 'table' }
      }
    ]
  },
  // {
  //   path: '/help',
  //   component: Layout,
  //   // redirect: '/cys/list',
  //   name: 'BusinessManage',
  //   meta: { title: '帮助中心', icon: 'icon-bangzhuzhongxin' },
  //   children: [
  //     {
  //
  //       path: 'customer',
  //       name: 'Customer',
  //       component: () => import('@/views/helpmodel/customer/index'),
  //       meta: { title: '在线客服', icon: 'table' }
  //     },
  //     {
  //
  //       path: 'issue',
  //       name: 'Issue',
  //       component: () => import('@/views/helpmodel/issue/index'),
  //       meta: { title: '自助解答', icon: 'table' }
  //     },
  //     {
  //       path: 'list',
  //       name: 'BusinessList',
  //       component: () => import('@/views/business/list'),
  //       meta: { title: '工单管理', icon: 'table' }
  //     }
  //
  //   ]
  // },
  // {
  //   path: '/message',
  //   component: Layout,
  //   redirect: '/message/history',
  //   name: 'MessageManage',
  //   meta: { title: '消息中心', icon: 'icon-bangzhuzhongxin' },
  //   children: [
  //     {
  //
  //       path: 'history',
  //       name: 'BusinessList',
  //       component: () => import('@/views/business/list'),
  //       meta: { title: '消息历史', icon: 'table' }
  //     },
  //     {
  //       path: 'notify',
  //       name: 'Notify',
  //       component: () => import('@/views/business/list'),
  //       meta: { title: '发布通知', icon: 'table' }
  //     }
  //   ]
  // },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/list',
    name: 'UserManage',
    meta: { title: '帐号管理', icon: 'icon-yonghu' },
    children: [
      {

        path: 'list',
        name: 'UserList',
        component: () => import('@/views/usermodel/user/index'),
        meta: { title: '用户', icon: 'table' }
      },
      {
        path: 'role',
        name: 'Role',
        component: () => import('@/views/usermodel/role/index'),
        meta: { title: '角色', icon: 'table' }
      },
      {

        path: 'menu',
        name: 'Menu',
        component: () => import('@/views/usermodel/menu/index'),
        meta: { title: '菜单', icon: 'table' }
      },
      {

        path: 'resource',
        name: 'Resource',
        component: () => import('@/views/usermodel/resource/index'),
        meta: { title: '资源', icon: 'table' }
      }
    ]
  },
  {
    path: '/system',
    component: Layout,

    name: 'SystemManage',
    meta: { title: '系统管理', icon: 'icon-xitong' },
    children: [
      {

        path: 'carType',
        name: 'CarTypeManage',
        component: () => import('@/views/sysmodel/carType/list'),
        meta: { title: '车型管理', icon: 'table' }
      },
      {
        path: 'city',
        name: 'CityManage',
        component: () => import('@/views/sysmodel/city/index'),
        meta: { title: '地区管理', icon: 'table' }
      },
      {

        path: 'list',
        name: 'BusinessList',
        component: () => import('@/views/sysmodel/goodsclassify/index'),
        meta: { title: '货品类型', icon: 'table' }
      },
      // {
      //
      //   path: 'setting',
      //   name: 'Setting',
      //   component: () => import('@/views/sysmodel/setting/index'),
      //   meta: { title: '参数设置', icon: 'table' }
      // }
    ]
  },
  // {
  //   path: '/server',
  //   component: Layout,
  //   // redirect: '/cys/list',
  //   name: 'ServerManage',
  //   meta: { title: '运维监控', icon: 'icon-yunweiguanli' },
  //   children: [
  //     {
  //
  //       path: 'list',
  //       name: 'BusinessList',
  //       component: () => import('@/views/business/list'),
  //       meta: { title: '日志中心', icon: 'table' }
  //     },
  //     {
  //       path: 'list',
  //       name: 'BusinessList',
  //       component: () => import('@/views/business/list'),
  //       meta: { title: '工单管理', icon: 'table' }
  //     },
  //     {
  //
  //       path: 'list',
  //       name: 'BusinessList',
  //       component: () => import('@/views/business/list'),
  //       meta: { title: '在线客服', icon: 'table' }
  //     }
  //   ]
  // },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
